package com.xioz.android;
/**
 * Tile Class
 * used to hold a character in a game board
 * 
 * @author Zong Xiong
 */
public class Tile extends GameObject{
	
/***************************************************
 * Fields
 ***************************************************/
	
	// wither or not this tile is shown or active
	private boolean visible;
	// stores character
	private char charValue;
	// stores point value of character
	private int pointValue;
	// wither or not this tile is selected
	private boolean selected;
	
/***************************************************
 * Public Methods
 ***************************************************/

	/**
	 * Default Constructor
	 * creates a tile with the letter A
	 * 
	 * @param x, lower-left x position
	 * @param y, lower-left y position
	 * @param width, width of tile
	 * @param height, height of tile
	 */
	public Tile(float x, float y, float width, float height) {
		super(x, y, width, height);
		reset();
		this.setChar('A');
	}
	
	/**
	 * Constructor with an assigned letter
	 * creates a tile with the assigned letter
	 * 
	 * @param x, lower-left x position
	 * @param y, lower-left y position
	 * @param width, width of tile
	 * @param height, height of tile
	 * @param inChar, assigned letter
	 */
	public Tile(float x, float y, float width, float height, char inChar) {
		super(x, y, width, height);
		reset();
		this.setChar(inChar);
	}
	
	/**
	 * setChar
	 * sets charValue to the inputed letter, and assigns the corresponding point value
	 * 
	 * @param input, input letter
	 */
	public void setChar(char input) {
		// assigns inputed letter
		this.charValue = input;
		
		// assigns point value corresponding to the letter
		switch (input) {
		case 'A': case 'E': case 'I': case 'O': case 'N': case 'R': case 'T': case 'L': case 'S': case 'U':
			this.pointValue=1;
			break;
		case 'D': case 'G':
			this.pointValue=2;
			break;
		case 'B': case 'C': case 'M': case 'P':
			this.pointValue=3;
			break;
		case 'F': case 'H': case 'V': case 'W': case 'Y':
			this.pointValue=4;
			break;
		case 'K':
			this.pointValue=5;
			break;
		case 'J': case 'X':
			this.pointValue=7;
			break;
		case 'Q': case 'Z':
			this.pointValue=9;
			break;
		}
	}
	
	/**
	 * getChar
	 * retrieves charValue
	 * 
	 * @return string equivalent of charValue
	 */
	public String getChar() {
		return Character.toString(this.charValue);
	}
	
	/**
	 * getPointValue
	 * retrieves point value of tile
	 * 
	 * @return point value of tile
	 */
	public int getPointValue() {
		return this.pointValue;
	}
	
	/**
	 * setVisibile
	 * sets the visibility of a tile
	 * 
	 * @param input, true for visible
	 */
	public void setVisible(boolean input) {
		this.visible = input;
	}
	
	/**
	 * isVisible
	 * retrieves if tile is visible
	 * 
	 * @return if tile is visible
	 */
	public boolean isVisible() {
		return this.visible;
	}

	/**
	 * setSelected
	 * assigns if wither or not the tile is selected
	 * 
	 * @param input, true if tile is selected
	 */
	public void setSelected(boolean input) {
		this.selected = input;
	}
	
	/**
	 * isSelected
	 * retrieves if tile is selected or not
	 * 
	 * @return true if the tile is selected
	 */
	public boolean isSelected() {
		return this.selected;
	}

	/**
	 * reset
	 * resets the tile to have no visibility and not be selected
	 */
	public void reset() {
		this.visible = true;
		this.selected = false;
	}
}
